import request from '@/utils/request'
import { transformRequest } from '@/api/utils/transform'
// import axios from 'axios'
// const CancelToken = axios.CancelToken

// 登录
export function login(data) {
  return request({
    url: 'api/login',
    headers: {
      'content-type': 'application/x-www-form-urlencoded'
    },
    method: 'post',
    data: transformRequest(data)
  })
}

// 修改密码
export function changePassword(data) {
  return request.post('api/staff/changePassword', null, {
    params: data
  })
}

// 刷新token
export function refreshToken(data) {
  return request({
    url: 'api/login/refreshToken',
    method: 'post',
    data: JSON.stringify(data)
  })
}

// 获取当前人员详情
export function getStaffById(params) {
  return request({
    url: 'api/staff/getDetailById',
    method: 'get',
    params: {
      staffId: params
    }
  })
}
// 获取当前人员权限
export function getGoldenServiceRole(data) {
  return request({
    url: 'api/staff/getGoldenServiceRole',
    method: 'post',
    data
  })
}
// 关键人详情页查询
export function getKeyByName(params) {
  return request({
    url: 'api/keyPersonDetailQuery/getByCustRowId',
    method: 'get',
    params
  })
}

// 金牌服务申请查询初始化页面
export function applySearch_init() {
  return request({
    url: 'api/goldenServiceApplySearch/init',
    method: 'get'
  })
}

// 根据贵宾卡号和部门经理id去查询关键人信息
export function queryKeyCust(params) {
  return request({
    url: 'api/goldenServiceApplyCreate/queryKeyCust',
    method: 'get',
    params: {
      ...params
    }
  })
}
// 根据关键人id去查询家属信息
export function queryFamilyInfo(params) {
  return request({
    url: 'api/goldenServiceApplyCreate/queryFamilyInfo',
    method: 'get',
    params: {
      ...params
    }
  })
}

// 金牌服务申请查询分页查询
export function applySearch_searchApply(data) {
  return request({
    url: 'api/goldenServiceApplySearch/searchApply',
    method: 'post',
    data: JSON.stringify(data)
  })
}

// 金牌服务创建初始化
export function goldenServiceApplyCreate_init() {
  return request({
    url: 'api/goldenServiceApplyCreate/init',
    method: 'get'
  })
}

// 金牌服务创建
export function goldenServiceApplyCreate_apply(data) {
  return request({
    url: 'api/goldenServiceApplyCreate/goldenServiceApplyCreate',
    method: 'post',
    data
  })
}

// 金牌普通查询页面初始化
export function goldenServiceQuery_initPage() {
  return request({
    url: 'api/goldenServiceQuery/initPage',
    method: 'get'
  })
}

// 金牌普通查询
export function goldenServiceQuery_search(data) {
  return request({
    url: 'api/goldenServiceQuery/search',
    headers: {
      'content-type': 'application/json'
    },
    method: 'post',
    data: JSON.stringify(data)
  })
}

// 关键人查询
export function searchByKeyPerson(params) {
  return request({
    url: 'api/goldenServiceQuery/searchByKeyPerson',
    method: 'get',
    params: {
      ...params
    }
  })
}

// 待审核页面
export function applyWaitAudit(data, querySelfOnly) {
  return request({
    url: 'api/goldenServiceApplyWaitAudit/getWaitAudit?querySelfOnly=' + querySelfOnly,
    method: 'post',
    data
  })
}

// 根据id查询详情信息
export function getDetailById(id) {
  return request({
    url: 'api/goldenServiceApplyDetail/getDetailById',
    method: 'get',
    params: {
      goldenServiceApplyId: id
    }
  })
}

// 审核金牌服务
export function audit(data) {
  return request({
    url: 'api/goldenServiceApplyDetail/audit',
    method: 'post',
    data: JSON.stringify(data)
  })
}

export function cancelGoldService(data) {
  return request({
    url: 'api/goldenServiceQuery/cancelGoldService',
    method: 'post',
    data: JSON.stringify(data)
  })
}

// 作废金牌服务

export function obsolote(data) {
  return request({
    url: 'api/goldenServiceApplyDetail/obsolete',
    method: 'post'
  })
}

// 作废金牌服务

export function getCurd(params) {
  return request({
    url: 'api/goldenServiceQuery/getServiceCardLinkListByGoldenServiceId',
    method: 'get',
    params
  })
}

// 部门初始化数据

export function initTempCreatePage() {
  return request({
    url: 'api/staff/initTempCreatePage',
    method: 'post'
  })
}

// 部门初始化数据

export function tempCreateStaff(data) {
  return request({
    url: 'api/staff/tempCreateStaff',
    method: 'post',
    data
  })
}

// 下载所有待审核的金牌服务申请
export function downloadWaitAuditAllGoldenService(data) {
  return request({
    url: 'api/goldenServiceApplyWaitAudit/downloadWaitAuditAllGoldenService',
    method: 'post',
    responseType: 'blob',
    data
  })
}

// 下载所有有效的的金牌服务
export function downloadEffectiveAllGoldenService(data) {
  return request({
    url: 'api/goldenServiceQuery/downloadEffectiveAllGoldenService',
    method: 'post',
    responseType: 'blob',
    data
  })
}

// 下载金牌服务数据excel
export function downloadExcelData(data, params) {
  return request({
    url: 'api/goldenServiceQuery/downloadExcelData',
    method: 'post',
    responseType: 'blob',
    data,
    params
  })
}

// 小红点
export function getWaitAuditCount() {
  return request({
    url: 'api/goldenServiceApplyWaitAudit/getWaitAuditCount',
    method: 'get'
  })
}

// 上传文件
export function createFile(data) {
  return request({
    url: 'api/DfsStorage/createFile',
    method: 'post',
    data
  })
}

// 下载文件
export function download(params, abortController) {
  return request({
    url: 'api/dfsStorage/download',
    method: 'get',
    responseType: 'blob',
    params,
    signal: abortController.signal
  })
}
//
// http://172.31.69.112:8080/api/dfsStorage/download?path=golden-service%2Fjpg--20230522103552225.jpg
// http://10.142.90.152:8997/webctdfs/file/dfs/test/test.log
// http://<host>:<port>/webctdfs/file/<scheme>/<point>/<path
export function download1(params) { // 直接调用下载 不通过后端
  return request({
    url: 'api/dfsStorage/download',
    method: 'get',
    responseType: 'blob',
    headers: {
      'webctdfs-username': '', // 系统分配的用户名。
      'webctdfs-timestamp': new Date().valueOf(), // 请求提交时的时间戳
      'webctdfs-token': '' // 将密码与时间戳相连后（密码内容在前，时间戳内容在后）以 MD5 形式编码得出。（参数内容字母大小写不敏感。
    },
    params
  })
}

// 更新验证
export function modifyFrontResourceTimeStamp(data) {
  return request({
    url: 'new/frontResource/modifyFrontResourceTimeStamp',
    method: 'post',
    data
  })
}

// 查询验证
export function getFrontResourceTimeStamp(params) {
  return request({
    url: 'api/frontResource/getFrontResourceTimeStamp',
    method: 'get',
    params
  })
}

// 查询验证
export function consultCreateApply(params) {
  return request({
    url: 'api/goldenServiceApplyCreate/consultCreateApply',
    method: 'get',
    params
  })
}

// 初始化
export function initGoldenServiceApplyHandled(params) {
  return request({
    url: 'api/goldenServiceApplyHandled/init',
    method: 'get',
    params
  })
}

// 初始化
export function getHandled(data) {
  return request({
    url: 'api/goldenServiceApplyHandled/getHandled',
    method: 'post',
    data
  })
}

// 初始化
export function goldenServiceApplyWaitAuditInit(params) {
  return request({
    url: 'api/goldenServiceApplyWaitAudit/init',
    method: 'get',
    params
  })
}

// 初始化
export function pageSearch(data) {
  return request({
    url: 'api/staff/pageSearch',
    method: 'post',
    data
  })
}

// 我的系统
export function getSelfSystemConfig(data) {
  return request({
    url: 'gateway/mainPage/getSelfSystemConfig',
    method: 'post',
    data
  })
}
// 外部跳转
export function getRcmLoginData(params) {
  return request({
    url: 'gateway/thirdSystem/getThirdSystemLoginData',
    method: 'post',
    params
  })
}

// 公告
export function systemAnnouncementRecord(params) {
  return request({
    url: 'api/index/systemAnnouncementRecord',
    method: 'get',
    params
  })
}

// 绿卡init
export function goldenServiceApplyGreenCardCreateInit(params) {
  return request({
    url: 'api/goldenServiceApplyGreenCardCreate/init',
    method: 'get',
    params
  })
}

// 创建绿卡服务
export function goldenServiceApplyGreenCardCreate(data) {
  return request({
    url: 'api/goldenServiceApplyGreenCardCreate/goldenServiceApplyGreenCardCreate',
    method: 'post',
    data
  })
}

// 批量创建绿卡服务
export function batchCreateGreenCardApply(data) {
  return request({
    url: 'api/goldenServiceApplyCreate/batchCreateGreenCardApply',
    method: 'post',
    data
  })
}


// 根据员工id去查询员工详情,可以查询已删除员工
export function getById(params) {
  return request({
    url: 'api/staff/getById',
    method: 'get',
    params
  })
}

// 取回服务卡
export function retrieve(data) {
  return request({
    url: 'api/goldenServiceApplyDetail/retrieve',
    method: 'post',
    data
  })
}

// 取回服务卡
export function getIfLimitByVipCardNo(params) {
  return request({
    url: 'api/goldenServiceApplyCreate/getIfLimitByVipCardNo',
    method: 'get',
    params
  })
}


// 取回服务卡
export function searchPreInvalid(data) {
  return request({
    url: 'api/goldenServiceQuery/searchPreInvalid',
    method: 'post',
    data
  })
}


export function queryManager(params) {
  return request({
    url: 'api/goldenServiceApplyCreate/queryManager',
    method: 'get',
    params
  })
}
